#ifdef _WIN32
#include "stdafx.h"
#endif

struct missile_manager
{
    object_pool<SceneNode *> nodes, targets;
    //object_pool<Entity *> entities;
    object_pool<float> velocities;

    SceneNode * root;
#ifdef USE_BULLET
    btCollisionWorld::ClosestConvexResultCallback sph_callback;
#endif

    void init(SceneNode * _root)
    {
        //sph_callback = btCollisionWorld::ClosestConvexResultCallback(
        root = _root;
        nodes.pool.resize(10,0);
        targets.pool.resize(10,0);
        velocities.pool.resize(10,0);
        FOR(10)
            nodes[i] = root->createChildSceneNode();
    }

    void add(SceneNode * emit, SceneNode * target, float velocity)
    {
        size_t a, b;
        nodes.add(a);
        root->addChild(nodes[a]);
        targets.add(b);
        targets[b] = target;
    }

    void update(float timeSinceLastFrame)
    {
        size_t s = nodes.size();
        for(size_t i = 0; i < s; ++ i)
        {
            if(nodes[i])
            {
                nodes[i]->lookAt(targets[i]->getPosition(), Node::TS_LOCAL);
                nodes[i]->translate(0, 0, - timeSinceLastFrame * velocities[i], Node::TS_LOCAL);
            }
        }
    }
};